﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Sendz.Domain
{
    public class UserEmailValidation
    {
        // Entity
        [HiddenInput(DisplayValue = false)]
        public Guid ValidationKey { get; set; }

        [DisplayName("Email Address")]
        [Required(ErrorMessage = "An email address is required")]
        [RegularExpression(@"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$", ErrorMessage = "Please enter a valid email address")]
        [StringLength(100, ErrorMessage = "Please ensure that the email from address you enter is less than 100 characters")] 
        public string ValidationEmail { get; set; }

        [HiddenInput(DisplayValue = false)]
        public bool IsValidated { get; set; }

        [HiddenInput(DisplayValue = false)]
        public DateTime? LastModified { get; set; }

        [HiddenInput(DisplayValue = false)]
        public DateTime CreatedOn { get; set; }

        // Parents
        public Guid UserKey { get; set; }
        public User User { get; set; }

        // Constructors
        public UserEmailValidation() 
        {
            this.ValidationKey = Guid.NewGuid();
            this.CreatedOn = DateTime.Now;
        }
        public UserEmailValidation(Guid userKey, string email)
        {
            this.ValidationKey = Guid.NewGuid();
            this.UserKey = userKey;
            this.ValidationEmail = email;
            this.CreatedOn = DateTime.Now;
        }
    }
}